// To parse this JSON data, do
//
//     final mediaFolders = mediaFoldersFromJson(jsonString);

import 'dart:convert';

import 'package:emby/model/image_tags.dart';

class MediaFolders {
  MediaFolders({
    this.items,
    this.totalRecordCount,
  });

  List<MediaFolder> items;
  int totalRecordCount;

  factory MediaFolders.fromRawJson(String str) => MediaFolders.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory MediaFolders.fromJson(Map<String, dynamic> json) => MediaFolders(
        items: List<MediaFolder>.from(json["Items"].map((x) => MediaFolder.fromJson(x))),
        totalRecordCount: json["TotalRecordCount"],
      );

  Map<String, dynamic> toJson() => {
        "Items": List<dynamic>.from(items.map((x) => x.toJson())),
        "TotalRecordCount": totalRecordCount,
      };
}

class MediaFolder {
  MediaFolder({
    this.name,
    this.serverId,
    this.id,
    this.etag,
    this.dateCreated,
    this.canDelete,
    this.canDownload,
    this.presentationUniqueKey,
    this.sortName,
    this.externalUrls,
    this.path,
    this.taglines,
    this.genres,
    this.remoteTrailers,
    this.providerIds,
    this.isFolder,
    this.parentId,
    this.type,
    this.studios,
    this.genreItems,
    this.tagItems,
    this.displayPreferencesId,
    this.tags,
    this.primaryImageAspectRatio,
    this.collectionType,
    this.imageTags,
    this.backdropImageTags,
    this.lockedFields,
    this.lockData,
  });

  String name;
  String serverId;
  String id;
  String etag;
  DateTime dateCreated;
  bool canDelete;
  bool canDownload;
  String presentationUniqueKey;
  String sortName;
  List<dynamic> externalUrls;
  String path;
  List<dynamic> taglines;
  List<dynamic> genres;
  List<dynamic> remoteTrailers;
  ProviderIds providerIds;
  bool isFolder;
  String parentId;
  String type;
  List<dynamic> studios;
  List<dynamic> genreItems;
  List<dynamic> tagItems;
  String displayPreferencesId;
  List<dynamic> tags;
  double primaryImageAspectRatio;
  String collectionType;
  ImageTags imageTags;
  List<dynamic> backdropImageTags;
  List<dynamic> lockedFields;
  bool lockData;

  factory MediaFolder.fromRawJson(String str) => MediaFolder.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory MediaFolder.fromJson(Map<String, dynamic> json) => MediaFolder(
        name: json["Name"],
        serverId: json["ServerId"],
        id: json["Id"],
        etag: json["Etag"],
        dateCreated: DateTime.parse(json["DateCreated"]),
        canDelete: json["CanDelete"],
        canDownload: json["CanDownload"],
        presentationUniqueKey: json["PresentationUniqueKey"],
        sortName: json["SortName"],
        externalUrls: List<dynamic>.from(json["ExternalUrls"].map((x) => x)),
        path: json["Path"],
        taglines: List<dynamic>.from(json["Taglines"].map((x) => x)),
        genres: List<dynamic>.from(json["Genres"].map((x) => x)),
        remoteTrailers: List<dynamic>.from(json["RemoteTrailers"].map((x) => x)),
        providerIds: ProviderIds.fromJson(json["ProviderIds"]),
        isFolder: json["IsFolder"],
        parentId: json["ParentId"],
        type: json["Type"],
        studios: List<dynamic>.from(json["Studios"].map((x) => x)),
        genreItems: List<dynamic>.from(json["GenreItems"].map((x) => x)),
        tagItems: List<dynamic>.from(json["TagItems"].map((x) => x)),
        displayPreferencesId: json["DisplayPreferencesId"],
        tags: List<dynamic>.from(json["Tags"].map((x) => x)),
        primaryImageAspectRatio: json["PrimaryImageAspectRatio"].toDouble(),
        collectionType: json["CollectionType"],
        imageTags: ImageTags.fromJson(json["ImageTags"]),
        backdropImageTags: List<dynamic>.from(json["BackdropImageTags"].map((x) => x)),
        lockedFields: List<dynamic>.from(json["LockedFields"].map((x) => x)),
        lockData: json["LockData"],
      );

  Map<String, dynamic> toJson() => {
        "Name": name,
        "ServerId": serverId,
        "Id": id,
        "Etag": etag,
        "DateCreated": dateCreated.toIso8601String(),
        "CanDelete": canDelete,
        "CanDownload": canDownload,
        "PresentationUniqueKey": presentationUniqueKey,
        "SortName": sortName,
        "ExternalUrls": List<dynamic>.from(externalUrls.map((x) => x)),
        "Path": path,
        "Taglines": List<dynamic>.from(taglines.map((x) => x)),
        "Genres": List<dynamic>.from(genres.map((x) => x)),
        "RemoteTrailers": List<dynamic>.from(remoteTrailers.map((x) => x)),
        "ProviderIds": providerIds.toJson(),
        "IsFolder": isFolder,
        "ParentId": parentId,
        "Type": type,
        "Studios": List<dynamic>.from(studios.map((x) => x)),
        "GenreItems": List<dynamic>.from(genreItems.map((x) => x)),
        "TagItems": List<dynamic>.from(tagItems.map((x) => x)),
        "DisplayPreferencesId": displayPreferencesId,
        "Tags": List<dynamic>.from(tags.map((x) => x)),
        "PrimaryImageAspectRatio": primaryImageAspectRatio,
        "CollectionType": collectionType,
        "ImageTags": imageTags.toJson(),
        "BackdropImageTags": List<dynamic>.from(backdropImageTags.map((x) => x)),
        "LockedFields": List<dynamic>.from(lockedFields.map((x) => x)),
        "LockData": lockData,
      };
}

class ProviderIds {
  ProviderIds();

  factory ProviderIds.fromRawJson(String str) => ProviderIds.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory ProviderIds.fromJson(Map<String, dynamic> json) => ProviderIds();

  Map<String, dynamic> toJson() => {};
}
